<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加客户信息</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../scripts/jquery-1.7.2.js"></script>
<script type="text/javascript" src="../scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.src.js"></script>
<script type="text/javascript" src="../scripts/pagekage/utils/widget/jqGrid/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="../scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.min.js"></script>

<!--[if IE 6]>
<script type="text/javascript" src="js/ie6png.js" ></script>
<script type="text/javascript">
DD_belatedPNG.fix('div,ul,li,a,p,img,body,dl,dt,dd');</script>
<![endif]-->
<script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
<script>
<!--
/*第一种形式 第二种形式 更换显示样式*/
function setTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hover":"";
con.style.display=i==cursel?"block":"none";
}
}
//-->
</script>
<script type="text/javascript">
//添加
    function ajaxPost(){
    	//alert("clientType"+$("input[name='clientType']:checked").val());
    	var client={
    		clientName:$("#clientName").val(),
    		phone:$("#phone").val(),
    		sex:$("input[name='sex']:checked").val(),
    		clientType:$("input[name='clientType']:checked").val(),
    		paperstType:$("#paperstType").val(),
    		paperstNo:$("#paperstNo").val(),
    		eduStatus:$("#eduStatus").val(),
    		profession:$("#profession").val(),
    		income:$("#income").val(),
    		maritalStatus:$("#maritalStatus").val(),
    		address:$("#address").val()
    	};
    	
    	alert("client"+client);
        $.ajax({ 	
        data: client,
        type:"Post",  
        dataType: 'json',  
        url:"/wangda/client/add.do", 
        error:function(data){  
             alert("出错了！！");  
        },  
        success:function(data){
        	alert('客户信息添加成功！');
        	window.location.href = 'listclient.jsp'; 
         }  
         });  
     } 
    // 重置
    function ajaxReset(){
    	$("#clientName").val("");
    	$("#phone").val("");
    	$("input:radio[name='sex']").eq(0).attr("checked",true);
    	$("input:radio[name='clientType']").eq(0).attr("checked",true);
    	$("#paperstType").val("");
		$("#paperstNo").val("");
		$("#eduStatus").val("");
		$("#profession").val("");
		$("#income").val("");
		$("#maritalStatus").val("");
		$("#address").val("");
    }
</script>
<script type="text/javascript">
   function checkClientName(){
	  var clientName= $("#clientName").val();
	  if(clientName==""){
		 alert("客户名称不能为空！"); 
		 $("#clientName").focus();
		 return false;
	  }
	  return true;
   }
   function checkPhone(){
	   var phone=$("#phone").val();
		  if(phone==""){
			 alert("联系电话不能为空！"); 
			 $("#phone").focus();
			 return false;
		  }
		  return true;
   }
   function Phone(){
	   var tel=$("#phone").val();
	   var phone=/^1\d{10}$/;
	   var mobile=/^0\d{2,3}-?\d{7,8}$/;
	   if (phone.test(tel) || mobile.test(tel)) { 
		      //alert("号码正确~"); 
		 }else{ 
		      alert("号码有误~"); 
		      $("#phone").focus();
		 };
   }
   function paperstNo(){
	   var no=$("#paperstNo").val();
	   var paperstNo=/^\d{17}([0-9]|X)$/;
	   if (paperstNo.test(no)) { 
		      //alert("身份证号码正确~"); 
		 }else{ 
		      alert("身份证号码有误~"); 
		      $("#paperstNo").focus();
		 };
   }
</script>
</head>
<body>
<div class="yboxwidth boxcenter">
  <div class="ybox09">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
       <td style="padding-left: 20px"><table border="0" cellspacing="0" cellpadding="0">
          <tr valign="top" >
            <td class="ybox11td5" ></td>
            <td class="ybox11td6" >填写客户基本信息</td>
            <td class="ybox11td7"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td4"></td>    
          </tr>
        </table></td>
        </tr>
    </table>
  </div>
  <div class="ybox02">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="margb4">
      <tr>
        <td class="ybox03td1"></td>
        <td class="ybox03td2"></td>
        <td class="ybox03td3"></td>
      </tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5"><div class="ybox05 margb8">
            <dl>
              <dt><strong>基本信息</strong> </dt>
            </dl>
          </div>
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox04table">
            <tr>
              <td width="15%" class="ybox04tdl"><span class="red">*</span>客户名称</td>
              <td width="18%" class="ybox04tdr"><input id="clientName" name="clientName"type="text"  class="black12" style="width:90%;" /></td>
              <td width="15%" class="ybox04tdl"><span class="red">*</span> 联系电话</td>
              <td width="18%" class="ybox04tdr"><input name="tel" type="text"  class="black12" id="phone" style="width:90%;" onblur="Phone()"/></td>
              <td width="15%" class="ybox04tdl">性别</td>
              <td width="18%" class="ybox04tdr">
                  <input type="radio" name="sex" value="男" checked="checked"/>男 &nbsp;&nbsp;&nbsp;
                  <input type="radio" name="sex" value="女"/>女
              </td>
            </tr>
          </table></td>
        <td class="ybox03td6"></td>
      </tr>
     <tr height="20" ><td colspan="6" bgcolor="#e9f7ff"></td></tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5"><div class="ybox05 margb8">
            <dl>
              <dt><strong>详细信息</strong> </dt>
            </dl>
          </div>
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox04table">
            <tr>
            <td width="15%" class="ybox04tdl"> 客户类型</td>
            <td width="18%" class="ybox04tdr">
                <input type="radio" name="clientType" id="clientType" value="个人" checked="checked"/>个人
                <input type="radio" name="clientType" id="clientType" value="公司"/>公司
            </td>
            <td width="15%" class="ybox04tdl"> 证件类型</td>
              <td width="18%" class="ybox04tdr">
                 <select name="paperstType" id="paperstType">
                    <option value="身份证">身份证</option>
                    <option value="汽车证">汽车证</option>
                    <option value="学生证">学生证</option>
                 </select>
              </td> 
              <td width="15%" class="ybox04tdl">证件号码 </td>
              <td width="18%" class="ybox04tdr"><input name="paperstNo" type="text"  class="black12" id="paperstNo" style="width:90%;" onblur="paperstNo()"/></td>    
            </tr>
             
            <tr>
              <td width="15%" class="ybox04tdl">教育程度 </td>
              <td width="18%" class="ybox04tdr"><input name="eduStatus" type="text"  class="black12" id="eduStatus" style="width:90%;" /></td>
              <td width="15%" class="ybox04tdl"> 职业</td>
              <td width="18%" class="ybox04tdr"><input name="profession" type="text"  class="black12" id="profession" style="width:90%;"  /></td>
              <td width="15%" class="ybox04tdl"> 收入层次</td>
              <td width="18%" class="ybox04tdr"><input name="income" type="text"  class="black12" id="income" style="width:90%;"  /></td>
              
            </tr>
            <tr>
            <td width="15%" class="ybox04tdl"> 婚姻状况</td>
              <td width="18%" class="ybox04tdr"><input name="maritalStatus" type="text"  class="black12" id="maritalStatus" style="width:90%;"  /></td>
              
              <td  class="ybox04tdl"> 通讯地址</td>
              <td width="18%" colspan="4" class="ybox04tdr"><input name="address" type="text"  class="black12" id="address" style="width:96%;"  /></td>
            </tr>
            <tr>
            <td width="18%" colspan="6" class="ybox04tdr">
              
               <dl>
                 <dt><strong>【注】</strong> 
                 1.基本信息为必填项</br>
                 2.详细信息必须在用户下订单之前填写完整
              </dt>
               </dl>
            </td>
            </tr>
            
          </table></td>
        <td class="ybox03td6"></td>
      </tr>
      <tr>
        <td class="ybox03td7"></td>
        <td class="ybox03td8"></td>
        <td class="ybox03td9"></td>
      </tr>
    </table>
    <table width="380" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="60" align="center"> <img src="images/bottoncommit.gif"  style="cursor: pointer;"width="95" height="34" onclick="return checkClientName()&& checkPhone()&& ajaxPost()" /></td>
        <td height="60" align="center"><img src="images/bottonreset.gif" style="cursor: pointer;" width="95" height="34" onclick="ajaxReset()" /></td>
      </tr>
    </table>
  </div>
</div>
</body>
</html>
